import Vue from 'vue';
import Router from 'vue-router';
Vue.use(Router);
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index')
  },
  {
    path: '/',
    component: () => import('@/views/studio/index')
  },
  {
    path: '/studio',
    component: () => import('@/views/studio/index')
  },
  {
    path: '/404',
    component: () => import('ecenter-ui/src/components/error-page/404'),
    hidden: true
  },
  {
    path: '/security',
    component: () => import('ecenter-ui/src/components/user/security'),
    hidden: true
  },
  {
    path: '/401',
    component: () => import('ecenter-ui/src/components/error-page/401'),
    hidden: true
  }
];
export const asyncRoutes = [
  { path: '*', redirect: '/404', hidden: true }
];

const createRouter = () => new Router({
  // mode: 'history', // require service support
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRoutes
});

const router = createRouter();

export function resetRouter() {
  const newRouter = createRouter();
  router.matcher = newRouter.matcher; // reset router
}

export default router;
